﻿using IDAL;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Remoting.Messaging;
using System.Text;

namespace DALMSSQL
{
    public class DBSessionFactory:IDAL.IDBSessionFactory
    {
        /// <summary>
        ///这个方法的作用:提高效率,在线程中共用一个DBsession对象
        /// </summary>
        /// <returns></returns>
        public IDBSession GetDBSession()
        {
            DBSession dBSession = CallContext.GetData(typeof(DBSessionFactory).Name) as DBSession;
            if (dBSession == null)
            {
                dBSession = new DBSession();
                CallContext.SetData(typeof(DBSessionFactory).Name, dBSession);
            }
            return dBSession;
        }
    } 
}
